<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('AGV/CTU执行队列列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>req_code：</label>
                            <input type="text" name="reqCode"/>
                        </li>
                        <li>
                            <label>下发时间：</label>
                            <input type="text" class="time-input" placeholder="请选择下发时间" name="reqTime"/>
                        </li>
                        <li>
                            <label>源站点：</label>
                            <input type="text" name="positionCode1"/>
                        </li>
                        <li>
                            <label>目标站点：</label>
                            <input type="text" name="positionCode2"/>
                        </li>
                        <li>
                            <label>优先级：</label>
                            <input type="text" name="priority"/>
                        </li>
                        <li>
                            <label>任务号：</label>
                            <input type="text" name="taskCode"/>
                        </li>
                        <li>
                            <label>任务号：</label>
                            <input type="text" name="taskNo"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <select id="isFinish" name="isFinish">
                                <option value="1">执行表</option>
                                <option value="2">历史表</option>
                            </select>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                               onclick="$.form.reset('formId','bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:execution:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="system:execution:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:execution:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:execution:export">
                <i class="fa fa-download"></i> 导出
            </a>
            <a class="btn btn-circle" onclick="reload()" shiro:hasPermission="system:execution:export">
                <i class="fa fa-download"></i> 重新下发
            </a>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:execution:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:execution:remove')}]];
    var prefix = ctx + "system/execution";


    function reload() {

        let rows = $("#bootstrap-table").bootstrapTable('getSelections');
        if (rows.length == 0) {
            $.modal.alertWarning("请选择至少一条数据")
            return
        }
        var guids = [];
        for (var i = 0; i < row.length; i++) {

            stockoutIds.push(row[i].guid);
        }
        $.ajax({
            "url": "/system/execution/reload",
            "type": "POST",
            "dataType": "json",
            "data": {guids: guids},
            "success": function (result) {
                if (result.code == 200) {
                    $.modal.alertSuccess(result.msg);
                    $.table.search();
                } else {
                    $.modal.alertWarning(result.msg);
                    $.table.search();
                }
            }
        });

    }


    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "AGV/CTU执行队列",
            clickToSelect: true,//是否启用点击选中行
            uniqueId: "reqCode",//表主键(用于修改和删除)
            sortName: "reqCode",//必加排序 sortOrder: "asc"默认
            columns: [
                {
                    halign: 'center',
                    align: 'center',
                    checkbox: true
                },
                {
                    title: "序号",
                    halign: 'center',
                    align: 'center',
                    width: 55,
                    formatter: function (value, row, index) {
                        //获取每页显示的数量
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;
                        //获取当前是第几页
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;
                        //返回序号，注意index是从0开始的，所以要加上1
                        return pageSize * (pageNumber - 1) + index + 1;

                    }
                },

                {
                    field: 'reqCode',
                    title: 'req_code',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'reqTime',
                    title: '下发时间',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'taskType',
                    title: '任务类型',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'positionCode1',
                    title: '源站点',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'positionCode2',
                    title: '目标站点',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'type',
                    title: '设备类型',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'priority',
                    title: '优先级',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'taskCode',
                    title: '任务号',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'status',
                    title: '任务状态',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                {
                    field: 'taskNo',
                    title: '任务号',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                // {
                //     field: 'spec',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'orderid',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                {
                    field: 'guid',
                    title: '唯一识别码',
                    halign: 'center',
                    align: 'center',
                    sortable: true,
                    visible: true
                },
                // {
                //     field: 'srcSite',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'tarSite',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'createDate',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'ctnrCode',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'ctnrTyp',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'agvType',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'warehouseId',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'qq',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'podCode',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
                // {
                //     field: 'podType',
                //     title: '',
                //     halign: 'center',
                //     align:'center',
                //     sortable: true,
                //     visible: true
                // },
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>